package com.meusdrinks.business;

import java.util.Date;
import java.util.List;

import br.gov.frameworkdemoiselle.lifecycle.Startup;
import br.gov.frameworkdemoiselle.stereotype.BusinessController;
import br.gov.frameworkdemoiselle.template.DelegateCrud;
import br.gov.frameworkdemoiselle.transaction.Transactional;

import com.meusdrinks.domain.Usuario;
import com.meusdrinks.persistence.UsuarioDAO;

@BusinessController
public class UsuarioBC extends DelegateCrud<Usuario, Long, UsuarioDAO> {
	
	private static final long serialVersionUID = 1L;
	
	@Startup
	@Transactional
	public void createUsers(){
		List<Usuario> users = findAll();
		if (users.isEmpty()){
			Usuario admin = new Usuario();
			admin.setDataNascimento(new Date());
			admin.setNome("Admin");
			admin.setPontos(0);
			insert(admin);
		}
	}
	
}
